package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Department;
import cn.wolfcode.mapper.DepartMapper;
import cn.wolfcode.query.QueryObject;
import cn.wolfcode.service.IDepartmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService extends ServiceImpl<DepartMapper,Department>
        implements IDepartmentService {

   /* @Autowired
    private DepartMapper departMapper;*/

   /* @Override
    public int deleteByPrimaryKey(Long id) {
        return departMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Department record) {
        return departMapper.insert(record);
    }

    @Override
    public Department selectByPrimaryKey(Long id) {
        return departMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Department> selectAll() {
        return departMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Department record) {
        return departMapper.updateByPrimaryKey(record);
    }*/

   /* @Override
    public PageInfo<Department> list(QueryObject qo) {
        //通过PageHelper进行设置分页及排序
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        //在SQL中不需要limit关键字
        List<Department> list = departMapper.selectList(qo);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }*/

    /*@Override
    public Workbook getWorkbook() {
       Workbook workbook = new HSSFWorkbook();
       Sheet sheet = workbook.createSheet("department");
       Row headrow = sheet.createRow(0);
       headrow.createCell(0).setCellValue("编号");
       headrow.createCell(1).setCellValue("名称");
       headrow.createCell(2).setCellValue("缩写");

       List<Department> departments = departMapper.selectAll();
       for (int i=0; i<departments.size();i++){
           Department department = departments.get(i);
           Row row = sheet.createRow(i+1);
           row.createCell(0).setCellValue(department.getId());
           row.createCell(1).setCellValue(department.getName());
           row.createCell(2).setCellValue(department.getSn());
       }
        return workbook;
    }*/
}
